from ronglian_sms_sdk import SmsSDK
accId = '8aaf07087bc82708017bf7d1aad10ed9'
accToken = 'e60ceb6cae53460bb0cf986b25023878'
appId = '8aaf07087bc82708017bf7d1abbd0ee0'

import json

def send_message():
    sdk = SmsSDK(accId, accToken, appId)
    tid = '1'
    datas = ('code', 'time')
    resp = sdk.sendMessage(accId, accToken, appId)
    result = json.loads(resp)
    if result['statusCode'] == '000000':
        return 1
    return 2

#redis连接
def get_redis_conn():
    from django_redis import get_redis_connection
    conn = get_redis_connection()
    return conn

#导入支付基类
from meiduo.utils.pay import AliPay

#初始化阿里支付对象
def get_ali_object():
    # 沙箱环境地址：https://openhome.alipay.com/platform/appDaily.htm?tab=info
    app_id = "2021000118631118"  #  APPID （沙箱应用）

    # 支付完成后，支付偷偷向这里地址发送一个post请求，识别公网IP,如果是 192.168.20.13局域网IP ,支付宝找不到，def page2() 接收不到这个请求
    notify_url = "http://localhost:8000/users/notify/"

    # 支付完成后，跳转的地址。
    return_url = "http://localhost:8000/users/notify/"

    merchant_private_key_path = "D:/p5python/meiduo/key/private.txt" # 应用私钥
    alipay_public_key_path = "D:/p5python/meiduo/key/pubilc.txt"  # 支付宝公钥

    alipay = AliPay(
        appid=app_id,
        app_notify_url=notify_url,
        return_url=return_url,
        app_private_key_path=merchant_private_key_path,
        alipay_public_key_path=alipay_public_key_path,  # 支付宝的公钥，验证支付宝回传消息使用，不是你自己的公钥
        debug=True,  # 默认False,
    )
    return alipay